
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原创作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证和
 *许可证下的限制。
 */

package org.springframework.jmx.export.notification;

import javax.management.Notification;

/**
 * Simple interface allowing Spring-managed MBeans to publish JMX notifications
 * without being aware of how those notifications are being transmitted to the
 * {@link javax.management.MBeanServer}.
 *
 * <p>Managed resources can access a {@code NotificationPublisher} by
 * implementing the {@link NotificationPublisherAware} interface. After a particular
 * managed resource instance is registered with the {@link javax.management.MBeanServer},
 * Spring will inject a {@code NotificationPublisher} instance into it if that
 * resource implements the {@link NotificationPublisherAware} interface.
 *
 * <p>Each managed resource instance will have a distinct instance of a
 * {@code NotificationPublisher} implementation. This instance will keep
 * track of all the {@link javax.management.NotificationListener NotificationListeners}
 * registered for a particular managed resource.
 *
 * <p>Any existing, user-defined MBeans should use standard JMX APIs for notification
 * publication; this interface is intended for use only by Spring-created MBeans.
 *
 * @author Rob Harrop
 * @since 2.0
 * @see NotificationPublisherAware
 * @see org.springframework.jmx.export.MBeanExporter
 */
/**
 *简单的接口允许Spring托管的MBean发布JMX通知
 *而不知道这些通知是如何传输到
 *｛@link javax.management.MBeanServer｝。
 *
 *<p>托管资源可以通过以下方式访问｛@code NotificationPublisher｝
 *实现{@linkNotificationPublisherware}接口。在一个特定的
 *托管资源实例在{@linkjavax.management.MBeanServer}中注册，
 *如果
 *资源实现了｛@link NotificationPublisherware｝接口。
 *
 *<p>每个托管资源实例都有一个不同的
 *｛@code NotificationPublisher｝实现。此实例将保留
 *跟踪所有｛@link javax.management.NotificationListener NotificationListeners｝
 *为特定的托管资源注册。
 *
 *<p>任何现有的用户定义的MBean都应该使用标准的JMX API进行通知
 *出版；该接口仅用于Spring创建的MBean。
 *
 *@作者Rob Harrop
 *@自2.0起
 *@请参阅NotificationPublisherware
 *@参见org.springframework.jmx.export.MBeanExport
 */
@FunctionalInterface
public interface NotificationPublisher {

	/**
	 * Send the specified {@link javax.management.Notification} to all registered
	 * {@link javax.management.NotificationListener NotificationListeners}.
	 * Managed resources are <strong>not</strong> responsible for managing the list
	 * of registered {@link javax.management.NotificationListener NotificationListeners};
	 * that is performed automatically.
	 * @param notification the JMX Notification to send
	 * @throws UnableToSendNotificationException if sending failed
	 */
	/**
	 *将指定的{@linkjavax.management.Notification}发送给所有注册的
	 *｛@link javax.management.NotificationListener NotificationListeners｝。
	 *托管资源不负责管理列表
	 *已注册的｛@link javax.management.NotificationListener NotificationListeners｝的；
	 *这是自动执行的。
	 *@param notification要发送的JMX通知
	 *如果发送失败，@throws UnableToSendNotificationException
	 */
	void sendNotification(Notification notification) throws UnableToSendNotificationException;

}
